package uit.nfc.utils;
import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;

/**
 * @author XIII
 */

public class WebServiceHelper {

	public static String callWebService(String url) {	
		HttpClient httpClient = new DefaultHttpClient();
		HttpGet request = new HttpGet(url);
		HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 10000);			
		ResponseHandler<String> responseHandler = new BasicResponseHandler();	
		String response = null;

		try {
			response = httpClient.execute(request, responseHandler);
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		httpClient.getConnectionManager().shutdown();
		
		return response;
	}
}
